﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;

namespace Grundy.Message
{
    
    [CollectionDataContract]
    public class FeatureCollection : ICollection<Feature>
    {
        private List<Feature> _features;

        public FeatureCollection()
        {
            _features = new List<Feature>();
        }

        public FeatureCollection(IEnumerable<Feature> features)
        {
            _features = features.ToList();
        }

        public IEnumerator<Feature> GetEnumerator()
        {
            return _features.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        public void Add(Feature item)
        {
            _features.Add(item);
        }

        public void Clear()
        {
            _features.Clear();
        }

        public bool Contains(Feature item)
        {
            return _features.Contains(item);
        }

        public void CopyTo(Feature[] array, int arrayIndex)
        {
            _features.CopyTo(array, arrayIndex);
        }

        public bool Remove(Feature item)
        {
            return _features.Remove(item);
        }

        public int Count
        {
            get { return _features.Count; }
        }

        public bool IsReadOnly
        {
            get { return false; }
        }
    }
}